// 深度遍历
const tree = {
  val: 'a',
  children: [
    {
      val: 'b',
      children: [
        {
          val: 'c',
          children: []
        }
      ]
    }
  ]
}

// const dfs = function (root) {
//   // console.log(root.val)
//   root.children.forEach(dfs())

// }

// dfs(tree)

const bfs = (root) => {
  const q = [root]
  while (q.length > 0) {
    const n = q.shift()
    console.log(n.val)
    n.children.forEach(child => {
      q.push(child)
    })
  }
}